const apiBaseURL = "http://127.0.0.1:8088/api/"
// axios实例
const service = axios.create({
	baseURL: apiBaseURL,
	timeout: 60000,
	headers: { 
		'Content-Type': 'application/json;charset=UTF-8'
	}
})


// 请求拦截器
service.interceptors.request.use(
	(config) => {
		config.headers['X-Requested-With'] = 'XMLHttpRequest'
		return config
	},
	error => {
		return Promise.reject(error)
	}
)

service.interceptors.response.use(
	async (response) => {
		
		if (response.status !== 200) {
			return Promise.reject(new Error(response.statusText || 'Error'))
		}

		const res = response.data
		if (Object.prototype.toString.call(res) === '[object Blob]') {
			return response
		}

		// 响应成功
		return  Promise.resolve(res)
	},
	error => {
		return Promise.reject(error)
	}
)


const Api = {
    testApi:()=>service.get("/demo2")
}